/*     */ package com.feeyin.radar.sys.service.impl;
/*     */ 
/*     */ import com.feeyin.radar.commons.StringUtils;
/*     */ import com.feeyin.radar.sys.dao.ManageSetDAO;
/*     */ import com.feeyin.radar.sys.dao.RoleDAO;
/*     */ import com.feeyin.radar.sys.form.AssessmentTypeForm;
/*     */ import com.feeyin.radar.sys.model.ManageSet;
/*     */ import com.feeyin.radar.sys.model.Role;
/*     */ import com.feeyin.radar.sys.service.AssessmentTypeService;
/*     */ import java.util.List;
/*     */ 
/*     */ public class AssessmentTypeServiceImpl
/*     */   implements AssessmentTypeService
/*     */ {
/*     */   private ManageSetDAO manageSetDAO;
/*     */   private RoleDAO roleDAO;
/*     */ 
/*     */   public ManageSetDAO getManageSetDAO()
/*     */   {
/*  24 */     return this.manageSetDAO;
/*     */   }
/*     */ 
/*     */   public void setManageSetDAO(ManageSetDAO manageSetDAO) {
/*  28 */     this.manageSetDAO = manageSetDAO;
/*     */   }
/*     */ 
/*     */   public RoleDAO getRoleDAO() {
/*  32 */     return this.roleDAO;
/*     */   }
/*     */ 
/*     */   public void setRoleDAO(RoleDAO roleDAO) {
/*  36 */     this.roleDAO = roleDAO;
/*     */   }
/*     */ 
/*     */   public List getAssessmentTypesTarget() {
/*  40 */     return this.manageSetDAO.getManageSetByType("11");
/*     */   }
/*     */ 
/*     */   public List getAssessmentTypesMaxLimit() {
/*  44 */     return this.manageSetDAO.getManageSetByType("12");
/*     */   }
/*     */ 
/*     */   public boolean updateAssessemntType(AssessmentTypeForm asTypeForm) {
/*  48 */     if (asTypeForm == null) return false;
/*     */ 
/*  50 */     boolean result1 = false;
/*  51 */     boolean result2 = false;
/*     */ 
/*  53 */     result1 = updateTarget(asTypeForm);
/*  54 */     result2 = updateLimit(asTypeForm);
/*     */ 
/*  56 */     return (result1) && (result2);
/*     */   }
/*     */ 
/*     */   public boolean isExpUser(Integer userId) {
/*  60 */     return this.manageSetDAO.isExpUser(userId);
/*     */   }
/*     */ 
/*     */   private boolean updateTarget(AssessmentTypeForm asTypeForm)
/*     */   {
/*  69 */     if ("isContract".equals(asTypeForm.getTargetCode())) {
/*  70 */       updateAssessmentTypeByCode("isContract", "1", "0", null, null);
/*  71 */       updateAssessmentTypeByCode("isBackCost", "0", "0", null, null);
/*  72 */       updateAssessmentTypeByCode("isGrossProfit", "0", "0", null, null);
/*  73 */       updateAssessmentTypeByCode("isHand", "0", "0", null, null);
/*  74 */       updateAssessmentTypeByCode("isGrossBackCost", "0", "0", null, null);
/*     */     }
/*  76 */     else if ("isBackCost".equals(asTypeForm.getTargetCode())) {
/*  77 */       updateAssessmentTypeByCode("isBackCost", "1", "0", null, null);
/*  78 */       updateAssessmentTypeByCode("isContract", "0", "0", null, null);
/*  79 */       updateAssessmentTypeByCode("isGrossProfit", "0", "0", null, null);
/*  80 */       updateAssessmentTypeByCode("isHand", "0", "0", null, null);
/*  81 */       updateAssessmentTypeByCode("isGrossBackCost", "0", "0", null, null);
/*     */     }
/*  83 */     else if ("isGrossProfit".equals(asTypeForm.getTargetCode())) {
/*  84 */       updateAssessmentTypeByCode("isGrossProfit", "1", asTypeForm.getGrossProfit(), null, null);
/*  85 */       updateAssessmentTypeByCode("isContract", "0", "0", null, null);
/*  86 */       updateAssessmentTypeByCode("isBackCost", "0", "0", null, null);
/*  87 */       updateAssessmentTypeByCode("isHand", "0", "0", null, null);
/*  88 */       updateAssessmentTypeByCode("isGrossBackCost", "0", "0", null, null);
/*     */     }
/*  90 */     else if ("isHand".equals(asTypeForm.getTargetCode())) {
/*  91 */       updateAssessmentTypeByCode("isHand", "1", "0", null, null);
/*  92 */       updateAssessmentTypeByCode("isContract", "0", "0", null, null);
/*  93 */       updateAssessmentTypeByCode("isBackCost", "0", "0", null, null);
/*  94 */       updateAssessmentTypeByCode("isGrossProfit", "0", "0", null, null);
/*  95 */       updateAssessmentTypeByCode("isGrossBackCost", "0", "0", null, null);
/*     */     }
/*  97 */     else if ("isGrossBackCost".equals(asTypeForm.getTargetCode())) {
/*  98 */       updateAssessmentTypeByCode("isGrossBackCost", "1", "0", null, null);
/*  99 */       updateAssessmentTypeByCode("isContract", "0", "0", null, null);
/* 100 */       updateAssessmentTypeByCode("isBackCost", "0", "0", null, null);
/* 101 */       updateAssessmentTypeByCode("isGrossProfit", "0", "0", null, null);
/* 102 */       updateAssessmentTypeByCode("isHand", "0", "0", null, null);
/*     */     }
/* 104 */     return true;
/*     */   }
/*     */ 
/*     */   private boolean updateLimit(AssessmentTypeForm asTypeForm)
/*     */   {
/* 112 */     if ("isUnify".equals(asTypeForm.getMaxLimitCode())) {
/* 113 */       updateAssessmentTypeByCode("isUnify", "1", asTypeForm.getUnifyLimit(), null, null);
/* 114 */       updateAssessmentTypeByCode("isTarget", "0", "0", null, null);
/* 115 */       updateAssessmentTypeByCode("isRole", "0", "0", null, null);
/*     */     }
/* 117 */     else if ("isTarget".equals(asTypeForm.getMaxLimitCode())) {
/* 118 */       updateAssessmentTypeByCode("isTarget", "1", asTypeForm.getTargetLimit(), null, null);
/* 119 */       updateAssessmentTypeByCode("isUnify", "0", "0", null, null);
/* 120 */       updateAssessmentTypeByCode("isRole", "0", "0", null, null);
/*     */     }
/* 122 */     else if ("isRole".equals(asTypeForm.getMaxLimitCode())) {
/* 123 */       updateAssessmentTypeByCode("isRole", "1", "0", asTypeForm.getRoleLimit(), asTypeForm.getRoleId());
/* 124 */       updateAssessmentTypeByCode("isUnify", "0", "0", null, null);
/* 125 */       updateAssessmentTypeByCode("isTarget", "0", "0", null, null);
/*     */     }
/*     */ 
/* 129 */     if ("isExpUser".equals(asTypeForm.getIsExpUser())) {
/* 130 */       updateAssessmentTypeByCode("isExpUser", "1", "0", null, asTypeForm.getUserId());
/*     */     }
/* 132 */     return true;
/*     */   }
/*     */ 
/*     */   private void updateAssessmentTypeByCode(String code, String status, String value, String[] roleLimits, Integer[] roleIds) {
/* 136 */     String expUserIds = "";
/* 137 */     if ("isExpUser".equals(code)) {
/* 138 */       expUserIds = StringUtils.getStringIdsByIntegerArray(roleIds);
/*     */     }
/*     */ 
/* 141 */     ManageSet manageSet = new ManageSet();
/* 142 */     manageSet.setCode(code);
/* 143 */     manageSet.setStatus(status);
/* 144 */     if (!StringUtils.isEmpty(expUserIds))
/* 145 */       manageSet.setMValue(expUserIds);
/*     */     else {
/* 147 */       manageSet.setMValue(value);
/*     */     }
/* 149 */     this.manageSetDAO.updateManageSetByCode(manageSet);
/*     */ 
/* 151 */     if (("isRole".equals(code)) && (roleLimits != null))
/* 152 */       for (int i = 0; i < roleLimits.length; i++) {
/* 153 */         Integer roleId = roleIds[i];
/* 154 */         String maxLimitNum = roleLimits[i];
/* 155 */         Role role = new Role();
/* 156 */         role.setId(roleId);
/* 157 */         role.setMaxLimitNum(Integer.valueOf(Integer.parseInt(maxLimitNum)));
/* 158 */         this.roleDAO.updateRoleMaxLimitNum(role);
/*     */       }
/*     */   }
/*     */ }

/* Location:           C:\Users\e547415\MyProject\rone\WEB-INF\classes\
 * Qualified Name:     com.feeyin.radar.sys.service.impl.AssessmentTypeServiceImpl
 * JD-Core Version:    0.6.0
 */